package com.wsl.sale.logback;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;

/**
 * @Author:wangshuliang
 * @Description:自定义过滤器
 * @Date:Created in 22:39 2019/5/2
 * @Modified by:
 */
public class SampleFilter extends Filter<ILoggingEvent> {
    // 默认false 即为不过滤
    boolean isFilter = false;

    public void setFilter(boolean filter) {
        isFilter = filter;
    }

    @Override
    public FilterReply decide(ILoggingEvent event) {
        System.out.println("sjkkkkkdnakjdakjsda  "+ event.getMessage());
        if (event.getMessage()!=null && event.getMessage().contains("wsl")&&isFilter){
            return FilterReply.ACCEPT;
        }else {
            return FilterReply.DENY;
        }
    }
}
